<!-- 公共文件 start -->
@extends('admin.public.base')
<!-- 公共文件 end -->
<style>
    table th {
        min-width: 10px !important;
    }
    .layui-card-header {
        padding-top: 10px !important;
    }
</style>
@section('content')
    <div class="x-nav">
    <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">财务报表</a>
        <a><cite>代理商资金流水</cite></a>
    </span>
        <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
           onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i>
        </a>
    </div>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-inline layui-show-xs-block">
                                <select name="store_id">
                                    <option value=""></option>
                                    @foreach($store as $val)
                                        @if(request()->input('store_id') == $val['id'])
                                            <option value="{{$val['id']}}" selected>{{$val['store_name']}}</option>
                                        @else
                                            <option value="{{$val['id']}}">{{$val['store_name']}}</option>
                                        @endif
                                    @endforeach
                                </select>
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" autocomplete="off" placeholder="开始时间" name="start" id="start" value="{{request()->input('start')}}">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <input class="layui-input" autocomplete="off" placeholder="截止时间" name="end" id="end" value="{{request()->input('end')}}">
                            </div>
                            <div class="layui-inline layui-show-xs-block">
                                <button id="search" class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;搜索</i>
                                </button>
                                <input type="hidden" id="export_excel" name="export_excel" value="0">
                                <button id="export_excel_btn" class="layui-btn" lay-submit="" lay-filter="sreach"><i
                                        class="layui-icon">&#xe65b;</i>导出Excel
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body">
                        @if(count($statistic))
                        {{$statistic['store_name']}}&nbsp;&nbsp;&nbsp;&nbsp;管理费入账<span style="color: red">{{$statistic['glf_recharge']}}元</span>&nbsp;&nbsp;&nbsp;&nbsp;贷款入账<span style="color: red">{{$statistic['hk_recharge']}}元</span>&nbsp;&nbsp;&nbsp;&nbsp;管理费出账<span style="color: red">{{$statistic['glf_out']}}元</span>&nbsp;&nbsp;&nbsp;&nbsp;贷款出账<span style="color: red">{{$statistic['hk_out']}}元</span>&nbsp;&nbsp;&nbsp;&nbsp;运费<span style="color: red">{{$statistic['yf']}}元</span>
                        @endif
                        <table class="layui-table layui-form" style="width: 100%">
                            <thead>
                            <tr>
                                <th>序号</th>
                                <th>日期</th>
                                <th>代理商</th>
                                <th>管理费入账</th>
                                <th>货款入账</th>
                                <th>管理费出账</th>
                                <th>货款出账</th>
                                <th>运费</th>
                                <th>管理费余额</th>
                                <th>货款余额</th>
                            </thead>
                            <tbody>
                            @foreach($data as $item)
                                <tr>
                                    <td>
                                        {{$item->id}}
                                    </td>
                                    <td>
                                        {{$item->created_at}}
                                    </td>
                                    <td>
                                        {{$item->store_name}}
                                    </td>
                                    <td>
                                        {{$item->glf_recharge}}
                                    </td>
                                    <td>
                                        {{$item->hk_recharge}}
                                    </td>
                                    <td>
                                        {{$item->glf_out}}
                                    </td>
                                    <td>
                                        {{$item->hk_out}}
                                    </td>
                                    <td>
                                        {{$item->yf}}
                                    </td>
                                    <td>
                                        {{$item->glf_balance}}
                                    </td>
                                    <td>
                                        {{$item->hk_balance}}
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                    <div class="layui-card-body ">
                        <div class="page">
                            {{ $data->links('admin/public/page') }}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        layui.use(['laydate', 'form'], function(){
            form = layui.form,laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#start', //指定元素
                type: 'datetime'
            });

            //执行一个laydate实例
            laydate.render({
                elem: '#end', //指定元素
                type: 'datetime'
            });
        });

        $("#export_excel_btn").on('click', function () {
            layer.load(2, {
                time: 10000
            });
            $("#export_excel").val(1)
        });
        $("#search").on('click', function () {
            layer.load(2, {
                time: 10000
            });
            $("#export_excel").val(0);
        });
    </script>
@endsection
